/************************************************************************************
* SavedPlaylist.h                                                                   *
*                                                                                   *
* Copyright (C) 2011 Varuna L Amachi                                                *
*                                                                                   *
* This program is free software; you can redistribute it and/or modify              *
* it under the terms of the GNU General Public License as published by              *
* the Free Software Foundation; either version 2 of the License, or any             *
* later version.                                                                    *
*                                                                                   *
* This program is distributed in the hope that it will be useful, but               *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY        *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for       *
* more details. You should have received a copy of the GNU General Public           *
* License along with this program; if not, write to the Free Software Foundation,   *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                       *
*                                                                                   *
*************************************************************************************/

#ifndef SAVEDPLAYLIST_H
#define SAVEDPLAYLIST_H

#include <QString>
#include <QDateTime>
#include <QAbstractItemModel>
#include <QList>


#include "common/CommonTypes.h"
#include "PlaylistEntry.h"

class SavedPlaylist: public QAbstractItemModel
{
    /**
      Store the index and trackIds in hidden columns and
      use them to access the tracks......
      Have a list that relflects the tracks in the
      map and use it to show the table.....
      */

    Q_OBJECT
    QString     m_playlistName;
    QDateTime   m_creationTime;
    QDateTime   m_lastModifiedTime;
    MediaRating m_rating;
    QString     m_comment;
    QList<PlaylistEntry *> *m_entries;

    void clear();
public:
    SavedPlaylist(QString name,
                  QDateTime createTime,
                  QDateTime modTime,
                  MediaRating rating = None,
                  QString comment = "");
    ~SavedPlaylist();

    QDateTime   creationTime();
    QDateTime   lastModifiefTime();
    QString     playlistName();
    MediaRating rating();
    QString     comment();
    QList<PlaylistEntry *> *entries();


    void        setRating(MediaRating rating);
    void        setComment(QString comment);
    void        setPlaylistEntries(QList<PlaylistEntry *> *entries);

    void        addToPlaylist(QString trackId);
    void        removeFromPlaylist(int index);
    void        moveUp(int index);
    void        moveDown(int index);

    int rowCount(const QModelIndex &parent) const;
    int columnCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;
    QModelIndex index(int row, int column, const QModelIndex &parent) const;
    QModelIndex parent(const QModelIndex &child) const;
    bool hasChildren(const QModelIndex &parent) const;

    bool operator==(SavedPlaylist& entry);
};

#endif // SAVEDPLAYLIST_H
